mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()
authorTakashi Iwai <tiwai@suse.de>
Fri, 31 May 2019 13:18:41 +0000 (15:18 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Jun 2019 22:16:58 +0000 (23:16 +0100)
commitc077256110c04fe75c0ab98c073f7adf3a102ef3
tree052f5a191eef30b17a16612c4a3cf27da38b9d0f
parent5408fbe907213fe307a867698585a7a24821a602
mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()

A few places in mwifiex_uap_parse_tail_ies() perform memcpy()
unconditionally, which may lead to either buffer overflow or read over
boundary.

This patch addresses the issues by checking the read size and the
destination size at each place more properly.  Along with the fixes,
the patch cleans up the code slightly by introducing a temporary
variable for the token size, and unifies the error path with the
standard goto statement.

Reported-by: huangwen <huangwen@venustech.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
[bwh: Backported to 4.19: adjust context]

Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name mwifiex-fix-heap-overflow-in-mwifiex_uap_parse_tail_.patch
drivers/net/wireless/marvell/mwifiex/ie.c